Skip to content

feat: allow security_opt and readonly_rootfs to be configured#787

Merged
DDtKey merged 5 commits intotestcontainers:mainfrom
gurinderu:main
May 4, 2025
Merged

feat: allow security_opt and readonly_rootfs to be configured#787
DDtKey merged 5 commits intotestcontainers:mainfrom
gurinderu:main

Conversation

@gurinderu
Copy link
Copy Markdown
Contributor

I want to implement a Talos test container, and there is no way to change some arguments.

docker run --rm -it \
  --name tutorial \
  --hostname talos-cp \
  --read-only \
  --privileged \
  --security-opt seccomp=unconfined \
  --mount type=tmpfs,destination=/run \
  --mount type=tmpfs,destination=/system \
  --mount type=tmpfs,destination=/tmp \
  --mount type=volume,destination=/system/state \
  --mount type=volume,destination=/var \
  --mount type=volume,destination=/etc/cni \
  --mount type=volume,destination=/etc/kubernetes \
  --mount type=volume,destination=/usr/libexec/kubernetes \
  --mount type=volume,destination=/opt \
  -e PLATFORM=container \
  ghcr.io/siderolabs/talos:v1.9.5

@netlify
Copy link
Copy Markdown

netlify bot commented May 4, 2025

Deploy Preview for testcontainers-rust ready!

Name Link
🔨 Latest commit bec2152
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-rust/deploys/68179940124da80008371e91
😎 Deploy Preview https://deploy-preview-787--testcontainers-rust.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Copy Markdown
Contributor

@DDtKey DDtKey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution! 🚀

I've left some minor comments, please take a look

@DDtKey DDtKey changed the title Add additional flags to the generic image feat: support security_opt and readonly_rootfs to be configured May 4, 2025
@DDtKey DDtKey changed the title feat: support security_opt and readonly_rootfs to be configured feat: allow security_opt and readonly_rootfs to be configured May 4, 2025
@gurinderu gurinderu requested a review from DDtKey May 4, 2025 16:44
@DDtKey DDtKey enabled auto-merge (squash) May 4, 2025 17:09
@DDtKey DDtKey merged commit 7db35a4 into testcontainers:main May 4, 2025
12 checks passed
@github-actions github-actions bot mentioned this pull request May 4, 2025
DDtKey pushed a commit that referenced this pull request May 4, 2025
## 🤖 New release

* `testcontainers`: 0.23.3 -> 0.24.0 (⚠ API breaking changes)

### ⚠ `testcontainers` breaking changes

```text
--- failure enum_variant_added: enum variant added on exhaustive enum ---

Description:
A publicly-visible enum without #[non_exhaustive] has a new variant.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#enum-variant-new
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.40.0/src/lints/enum_variant_added.ron

Failed in:
  variant CmdWaitFor:Exit in /tmp/.tmpPG1hwc/testcontainers-rs/testcontainers/src/core/wait/cmd_wait.rs:16
  variant ClientError:PauseContainer in /tmp/.tmpPG1hwc/testcontainers-rs/testcontainers/src/core/client.rs:81
  variant ClientError:UnpauseContainer in /tmp/.tmpPG1hwc/testcontainers-rs/testcontainers/src/core/client.rs:83
  variant ClientError:PauseContainer in /tmp/.tmpPG1hwc/testcontainers-rs/testcontainers/src/core/client.rs:81
  variant ClientError:UnpauseContainer in /tmp/.tmpPG1hwc/testcontainers-rs/testcontainers/src/core/client.rs:83

--- failure enum_variant_missing: pub enum variant removed or renamed ---

Description:
A publicly-visible enum has at least one variant that is no longer available under its prior name. It may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.40.0/src/lints/enum_variant_missing.ron

Failed in:
  variant CmdWaitFor::ExitCode, previously in file /tmp/.tmp7IxuhL/testcontainers/src/core/wait/cmd_wait.rs:16

--- failure trait_method_added: pub trait method added ---

Description:
A non-sealed public trait added a new method without a default implementation, which breaks downstream implementations of the trait
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#trait-new-item-no-default
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.40.0/src/lints/trait_method_added.ron

Failed in:
  trait method testcontainers::core::ImageExt::with_user in file /tmp/.tmpPG1hwc/testcontainers-rs/testcontainers/src/core/image/image_ext.rs:171
  trait method testcontainers::core::ImageExt::with_readonly_rootfs in file /tmp/.tmpPG1hwc/testcontainers-rs/testcontainers/src/core/image/image_ext.rs:174
  trait method testcontainers::core::ImageExt::with_security_opt in file /tmp/.tmpPG1hwc/testcontainers-rs/testcontainers/src/core/image/image_ext.rs:177
  trait method testcontainers::ImageExt::with_user in file /tmp/.tmpPG1hwc/testcontainers-rs/testcontainers/src/core/image/image_ext.rs:171
  trait method testcontainers::ImageExt::with_readonly_rootfs in file /tmp/.tmpPG1hwc/testcontainers-rs/testcontainers/src/core/image/image_ext.rs:174
  trait method testcontainers::ImageExt::with_security_opt in file /tmp/.tmpPG1hwc/testcontainers-rs/testcontainers/src/core/image/image_ext.rs:177
```

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

## [0.24.0] - 2025-05-04

### Details
#### Features
- Support waiting for commands exit regardless of exit code (#771)
- Add user configuration for container commands (#784)
- Add option to stop containers with a timeout (#779)
- Support `pause` and `unpause` container (#785)
- Allow `security_opt` and `readonly_rootfs` to be configured (#787)

#### Miscellaneous Tasks
- Update etcetera requirement from 0.8.0 to 0.9.0 (#773)
- Update etcetera requirement from 0.9.0 to 0.10.0 (#775)
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@kiview
Copy link
Copy Markdown
Member

kiview commented May 6, 2025

@DDtKey In other languages (Java, Go, .Net and Node.js should be relatively consistent here) we have the general pattern, of not allowing all properties to be configured in the main public API, but instead relying on a mechanism to drop onto the Docker API abstraction level, hence exposing all available option here.

Maybe worthwhile to consider for tc-rust as well.

Edit:
Looks like https://docs.rs/bollard/latest/bollard/struct.Docker.html#method.update_container does this job already 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants